package com.msg.test.model;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

/**
 * Created by Administrator on 2017/10/20 0020.
 */
public class MsgSubmitResp extends MsgHead{
    private static Log log = LogFactory.getLog(MsgSubmitResp.class);
    private long msgId;
    private byte result;

    public MsgSubmitResp(byte[] data){
        ByteArrayInputStream bins = new ByteArrayInputStream(data);
        DataInputStream dins = new DataInputStream(bins);
        if (data.length == 8+8+1) {
            try {
                this.setTotalLength(data.length + 4);
                this.setCommandId(dins.readInt());
                this.setSequence(dins.readInt());
                this.msgId = dins.readLong();
                this.result = dins.readByte();
                dins.close();
                bins.close();
            } catch (IOException ex) {

            }
        }else {
            log.info("发送短信IMSP回复，解析数据包出错，包长度不一致。长度为：" + data.length);
        }

    }
    public long getMsgId() {
        return msgId;
    }

    public void setMsgId(long msgId) {
        this.msgId = msgId;
    }

    public byte getResult() {
        return result;
    }

    public void setResult(byte result) {
        this.result = result;
    }
}
